package seqprint;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author DELL shiny
 * @create 2020/1/2
 */
public class SeqPrint {

    private AtomicInteger count=new AtomicInteger(0);

    public static void main(String[] args) throws InterruptedException {
        final CountDownLatch latch = new CountDownLatch(100);
        SeqPrint seqPrint=new SeqPrint();
        for (int i = 0; i < 100 ; i++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    seqPrint.inc();
                    latch.countDown();
                    System.out.println(seqPrint.count);
                }
            }).start();
        }
        latch.await();
        System.out.println(seqPrint.count);
    }

    public void inc(){
        count.incrementAndGet();
    }
}
